package com.ning.cms.web.controller;

import com.ning.cms.TO.LoginTO;
import com.ning.cms.service.UserService;
import com.ning.common.web.response.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "认证模块")
@RequestMapping("/auth")
@RestController
public class AuthController {
    @Autowired
    private UserService userService;

    @ApiOperation(value = "登陆",notes = "用户名和密码")
    @PostMapping("/login")
    public Result login(@RequestBody @ApiParam("登陆类") LoginTO loginTO){
        String token = userService.login(loginTO);

        return Result.success(token);
    }
}
